//
//  LeverageTradeHeaderView.m
//  XTXOneToOne
//
//  Created by Canny on 2018/10/29.
//  Copyright © 2018年 WK. All rights reserved.
//

#import "LeverageTradeHeaderView.h"

@interface LeverageTradeHeaderView ()



@end


@implementation LeverageTradeHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor=[UIColor whiteColor];
        [self createUI];
    }
    return self;
}
-(void)setLab:(UILabel *)lab withColor:(UIColor *)color andFont:(CGFloat)font andText:(NSString *)text andTextAlignment:(NSTextAlignment)textAlignment{
    lab.text=text;
    lab.textColor=color;
    lab.font=[UIFont systemFontOfSize:font];
    lab.textAlignment=textAlignment;
}
-(void)createUI{
    
    [self createLeftBtn];
    [self createRightBtn];
    
    UILabel * USDT = [[UILabel alloc]init];
    [self addSubview:USDT];
    [self setLab:USDT withColor:RGB(197, 207, 213) andFont:12 andText:@"可用USDT" andTextAlignment:NSTextAlignmentLeft];
    [USDT mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(20));
        make.width.equalTo(@(100));
        make.left.equalTo(self.mas_left).offset(15);
        make.bottom.equalTo(self.mas_bottom).offset(-30);
    }];
    _USDT = USDT;
    
    _USDTLab = [[UILabel alloc]init];
    [self addSubview:_USDTLab];
    [self setLab:_USDTLab withColor:RGB(31, 63, 89) andFont:12 andText:@"0" andTextAlignment:NSTextAlignmentLeft];
    [_USDTLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(20));
        make.width.equalTo(@(200));
        make.left.equalTo(self.mas_left).offset(15);
        make.bottom.equalTo(self.mas_bottom).offset(-50);
    }];
    
    
    UILabel * BTC = [[UILabel alloc]init];
    [self addSubview:BTC];
    [self setLab:BTC withColor:RGB(197, 207, 213) andFont:12 andText:@"可用BTC" andTextAlignment:NSTextAlignmentLeft];
    [BTC mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(20));
        make.width.equalTo(@(100));
        make.left.equalTo(self.mas_left).offset(G_SCREENWIDTH/2.0);
        make.bottom.equalTo(self.mas_bottom).offset(-30);
    }];
    _BTC = BTC;
    
    _BTCLab = [[UILabel alloc]init];
    [self addSubview:_BTCLab];
    [self setLab:_BTCLab withColor:RGB(31, 63, 89) andFont:12 andText:@"0" andTextAlignment:NSTextAlignmentLeft];
    [_BTCLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(20));
        make.width.equalTo(@(100));
        make.left.equalTo(self.mas_left).offset(G_SCREENWIDTH/2.0);
        make.bottom.equalTo(self.mas_bottom).offset(-50);
    }];
    
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:243/255.0 alpha:1];
    [self addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(10));
        make.width.equalTo(@(G_SCREENWIDTH));
        make.left.equalTo(self.mas_left).offset(0);
        make.bottom.equalTo(self.mas_bottom).offset(0);
    }];

}

-(void)createRightBtn{
    UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setTitle:@"" forState:UIControlStateNormal];
    [backBtn setTitleColor:RGB(255, 255, 255) forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(GoToK_Line) forControlEvents:UIControlEventTouchUpInside];
    backBtn.imageView.frame=CGRectMake(0, 0, 18, 32);
    //    [backBtn setImage:[UIImage imageNamed:@"图层-6"] forState:UIControlStateNormal];
    [self addSubview:backBtn];
    backBtn.backgroundColor=MC_TEST_COLOR;
    backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    backBtn.titleLabel.font=[UIFont systemFontOfSize:15];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(TopBackButtonHeight);
        make.right.equalTo(self.mas_right).offset(0);
        make.height.equalTo(@(32));
        make.width.equalTo(@(80));
    }];
    UIImageView * logo = [[UIImageView alloc]init];
    [backBtn addSubview:logo];
    //    logo.backgroundColor=[UIColor cyanColor];
    [logo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(backBtn.mas_centerY).offset(0);
        make.right.equalTo(backBtn.mas_right).offset(-10);
        make.height.equalTo(@(20));
        make.width.equalTo(@(20));
    }];
    logo.image=[UIImage imageNamed:@"折线图btn"];
}

-(void)createLeftBtn{
    UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setTitle:@"" forState:UIControlStateNormal];
    [backBtn setTitleColor:RGB(255, 255, 255) forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(openMenu) forControlEvents:UIControlEventTouchUpInside];
    backBtn.imageView.frame=CGRectMake(0, 0, 18, 32);
    //    [backBtn setImage:[UIImage imageNamed:@"图层-6"] forState:UIControlStateNormal];
    [self addSubview:backBtn];
    backBtn.backgroundColor=MC_TEST_COLOR;
    backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    backBtn.titleLabel.font=[UIFont systemFontOfSize:15];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(TopBackButtonHeight);
        make.left.equalTo(self.mas_left).offset(-20);
        make.height.equalTo(@(32));
        make.width.equalTo(@(150));
    }];
    
    UIImageView * logo = [[UIImageView alloc]init];
    [backBtn addSubview:logo];
//    logo.backgroundColor=[UIColor cyanColor];
    [logo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(backBtn.mas_centerY).offset(0);
        make.left.equalTo(backBtn.mas_left).offset(30);
        make.height.equalTo(@(20));
        make.width.equalTo(@(20));
    }];
    logo.image=[UIImage imageNamed:@"更多btn"];
    
    UILabel * title = [[UILabel alloc]init];
    [backBtn addSubview:title];
    title.text=@"加载中...";
    title.font = [UIFont systemFontOfSize:15];
    title.textColor=RGB(108, 138, 214);
    [title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(backBtn.mas_centerY).offset(0);
        make.left.equalTo(logo.mas_right).offset(10);
        make.height.equalTo(@(20));
        make.width.equalTo(@(80));
    }];
    _title=title;
}

-(void)openMenu{
    if (self.leftBtnBlock) {
        self.leftBtnBlock();
    }
}

-(void)GoToK_Line{
    if (self.rightBtnBlock) {
        self.rightBtnBlock();
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end














